#ifndef __MODULEMIXER_H__
#define __MODULEMIXER_H__
#include <iostream>
#include <stdexcept>
#include <vector>
#include <cstdio>
#include <cstring>
#include "ModuleConstants.h"

namespace modx {

	typedef struct _MixChn {
		char				*data;
		unsigned long		pos;
		unsigned long		inc;
		unsigned long		vol;
		unsigned long		length;
		unsigned long		loopStart;
		unsigned long		loopLength;
	} MixChn;
	
	class ModuleMixer {
	
	public:
		ModuleMixer(unsigned long sampleRate, int channels);
		~ModuleMixer();

		unsigned long out16(short in[], unsigned long nSamples);
		
		unsigned long getSampleRate();
		
		void freeChannels();
		int getNumChannels();
		void setNumChannels(int nCh);
		
		MixChn* getChannel(int cx);

	
	private:
		unsigned long m_lSampRate;
		int m_iChannels;
		std::vector<MixChn*> m_vChn;
	};
}


#endif
